package com.itfreer.power.service.jurisdiction;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.imp.DictionaryServiceImp;
import com.itfreer.form.dictionary.base.DictionaryItem;
import com.itfreer.power.dao.jurisdiction.MenuJurisdictionDao;
import com.itfreer.power.entity.jurisdiction.MenuJurisdictionEntity;

@Component("menuJurisdictionService")
public class MenuJurisdictionServiceBase extends DictionaryServiceImp<MenuJurisdictionEntity> implements MenuJurisdictionService {

	@Autowired
	private MenuJurisdictionDao menuJurisdictionDao;

	@Override
	protected BaseDao<MenuJurisdictionEntity> getDao() {
		return menuJurisdictionDao;
	}

	@Override
	public String getDictionaryName() {
		return "p_menu_jurisdiction";
	}

	@Override
	protected DictionaryItem convert(MenuJurisdictionEntity entity) {
		DictionaryItem toEntity = new DictionaryItem();
		BeanUtils.copyProperties(entity, toEntity);
		toEntity.getOther().put("urls", entity.getUrls());
		toEntity.getOther().put("registerService", entity.getRegisterService());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "id,pid,code,display,valid,leaf,order,urls,registerService";
	}
}